﻿namespace ApiTemplate.WebApi
{
    /// <summary>
    /// 调度任务
    /// </summary>
    public static class SchedulerSetup
    {
        /// <summary>
        /// 调度任务
        /// </summary>
        /// <param name="services"></param>
        /// <param name="appSetting"></param>
        public static void AddSchedulerSetup(this IServiceCollection services, AppSetting appSetting)
        {
            if (appSetting.EnableSchedulerTask)
            {
                services.AddQuartz(quartz =>
                {
                    quartz.UseMicrosoftDependencyInjectionScopedJobFactory(x =>
                    {
                        x.AllowDefaultConstructor = false;
                        x.CreateScope = true;
                    });
                });
            }
        }
    }
}
